// pages/tradeLine/tradeLine.js
import {GETTRADELINELIST, GETMYTRANDELIST, ISCOLLECTION} from "../../utils/api";
import {ajax} from "../../utils/httpRequest";

Page({

  /**
   * 页面的初始数据
   */
  data: {
    colorList: [
      {name: '白色', type: 1},
      {name: '绿色', type: 2},
      {name: '蓝色', type: 3},
      {name: '紫色', type: 4},
      {name: '我的收藏', type: 5}
    ],
    colorcurrentindex: 0,
    type: 'my',
    colorType: 1,
    gain: '',
    wordList: [{
      word: '林',
      min_money: 12.22,
      standard_price: 12.22,
      minimum: 12,
      z_number: 45,
      follow: 0,
      quality: 4,
      gain: 1
    }],
    myWordList: [
      {
        details: {
          word: '林',
          min_money: 12.22,
          standard_price: 12.22,
          minimum: 12,
          z_number: 45,
          follow: 0,
          quality: 4,
          gain: 1
        }
      },

    ],
    userNumber: '',
    inputVal: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // this.initData()
  },
  initData() {
    ajax.get(GETTRADELINELIST, {
      type: this.data.colorType,
      gain: this.data.gain,
      word: this.data.inputVal
    }).then(res => {
      console.log(res.data);
      // this.setData({
      //   userNumber:res.data.user_numberl,
      //   wordList:res.data.word_list
      // });
    })
  },
  getMyWordList() {
    ajax.get(GETMYTRANDELIST, {}).then(res => {
      this.myWordList = res.data;
      console.log(res.data);
    })
  },
  chooseColor(index, type) {
    this.colorcurrentindex = index;
    this.colorType = type;
    this.gain = '';
    this.inputVal = '';
    this.initData();
  },
  topNavClick(e) {
    if (e.target.dataset.type) {
      this.setData({
        type: e.target.dataset.type
      })
      if (this.data.type == 'all') {

      } else {

      }
    }
  },
  toDetails(){
    wx.navigateTo({
      url: '/pages/wordDetails/wordDetails',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})